﻿// JScript 文件

// (1) 对象句柄
if(typeof($)!="function")
{
	$ = function(_this) {
		return document.getElementById(_this);
	}
}

 String.prototype.trim = function() {                return this.replace(/^\s+/g,"").replace(/\s+$/g,"");     }
// (2) 获取url参数
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    var context = "";
    if (r != null)
        context = r[2];

    reg = null;
    r = null;

    return context == null || context == "" || context == "undefined" ? "" : context;
}

// (3) 字符串处理函数
// var sb = new StringBuilder();
// sb.append("test");
// sb.toString();
function StringBuffer() {
    this._string = new Array();
}

StringBuffer.prototype.append = function(value) {
    this._string.push(value);
}

StringBuffer.prototype.toString = function() {
    return this._string.join("");
}

StringBuffer.prototype.clear = function() {
    this._string.length = 1;
}
// 数值四舍五入
function round(v,len){

var t=1;

for(;len>0;t*=10,len--);

for(;len<0;t/=10,len++);

return Math.round(v*t)/t;

}

// (4)日期补0
function appendZero(s){ return ("00"+s).substr((s+"").length);}


Common = new function()
{
    this.$ = function(name)
	{
		return document.getElementById(name);
	}
	
	this._ = function(tagName)
	{
		return document.createElement(tagName);
	}
	
	this.AppendDataArray = function(id,url)
	{
		var obj = Common.$(id);
		if(obj){obj.parentNode.removeChild(obj);}
		var newscript = Common._("script");
		newscript.type = "text/javascript";
		newscript.src = url;
		newscript.id = id;
		//document.body.appendChild(newscript);
		document.getElementsByTagName('head')[0].appendChild(newscript);
	}
}

 function TextFocus(id){
  var HX_VALUE_ID=document.getElementById(id);
  HX_VALUE_ID.value="";
  HX_VALUE_ID.focus();
 }


